package com.zack.designPattern.flyweight;

public class Demo {

	public static void main(String[] args) {
		
		//简单享元
		FlyWeightFactory menuFactory = new FlyWeightFactory();
		FlyWeightMenu waterMenu = menuFactory.getMenu("水单");
		FlyWeightMenu dishMenu = menuFactory.getMenu("菜单");
		waterMenu.orderDish("张三", "可乐");
		dishMenu.orderDish("李四", "鱼香肉丝");
		
		//复合享元
		UnsharedFlyWeightPersonalMenu privacyMenu = new UnsharedFlyWeightPersonalMenu("张三的私房菜");
		privacyMenu.addCommonMenu(menuFactory.getMenu("水单"));
		privacyMenu.orderDish("张三", "张三家乡菜");
		
	}

}
